***************** Replication of Franchino, Fabio, and Camilla Mariotto. “Bargaining Outcomes and Success in EU Economic Governance Reforms”. Political Science Research and Methods.
version 15
pause on

do "Tables_1_2.do" /* need to run this do file first */

log using tables_A4_to_A7, replace

* Legend:
* nbs "nash bargaining solution, with reference point"
* nbs_norp "nash bargaining solution, without reference point"
* comp "compromise model, without reference point"
* comp2 "compromise model, 6-country power in QMV without reference point"
* comp3 "compromise model (Thomson power weights), without reference point"
* m_mean "mean model solution"
* minimax "minimax solution"
* PROCrp "procedural model with reference point"
* PROCnorp "procedural model without reference point"

*************   Table A6
* Cells for Table A6 (means and st.dev)
sum compAD /* column 1 row 1 - same as column 1 row 6 of Table 1 */
sum comp /* column 2 row 1 - same as column 2 row 6 of Table 1 */

gen comp2AD=abs( comp2 - outcome )
label variable comp2AD "=abs( comp2 - outcome )"
sum comp2AD /* column 1 row 2 */

sum comp2 /* column 2 row 2 */

gen comp2compAD=abs( comp2 - comp )
label variable comp2compAD "=abs( comp2 - comp )"
sum comp2compAD /* column 3 row 2 */

gen comp3AD=abs( comp3 - outcome )
label variable compAD "=abs( comp3 - outcome )"
sum comp3AD

sum comp3

gen comp3compAD=abs( comp3 - comp )
label variable comp3compAD "=abs( comp3 - comp )"
sum comp3compAD

gen comp2comp3AD=abs( comp2 - comp3 )
label variable comp2comp3AD "=abs( comp2 - comp3 )"
sum comp2comp3AD

*************   Table A4
* Cells for Table A4 (means and st.dev)
* Unanimity & Consultation (column 1)
sum PROCrpAD PROCnorpAD nbsAD nbs_norpAD compAD m_meanAD minimaxAD comp2AD comp3AD if cou_rule == 1

* QMV & Consultation (column 2)
sum PROCrpAD PROCnorpAD nbsAD nbs_norpAD compAD m_meanAD minimaxAD comp2AD comp3AD if cou_rule == 2 & ep_rule == 1

* OLP (column 3)
sum PROCrpAD PROCnorpAD nbsAD nbs_norpAD compAD m_meanAD minimaxAD comp2AD comp3AD if cou_rule == 2 & ep_rule == 2

*************   Table A6
* Two-sided sign tests for Table A6
* (see Table 1 for tests for the Compromise model  - COMP)
signtest	outcome	=	comp2 /* column 1 row 2 */
signtest	outcome	=	comp3 /* column 1 row 3 */

signtest	sq	=	comp2 /* column 2 row 2 */
signtest	sq	=	comp3

signtest	comp	=	comp2
signtest	comp	=	comp2

signtest	comp2	=	comp3


*************   Table A7
* The table after the command displays the cells in Table A7
* Below are the one-sided sign tests for Table A7
signtest	compAD		=	comp2AD
signtest	compAD		=	comp3AD
signtest	comp2AD	=	comp3AD


*************   Table A5
* Mean Euclidean Errors for Table A5
use data_signtest.dta, clear
gen meePROCrp = ( PROCrp - outcome )^2
sort act
by act: egen TmeePROCrp = mean(meePROCrp)
collapse (mean) TmeePROCrp, by(act)
replace TmeePROCrp = sqrt(TmeePROCrp)
collapse (mean) TmeePROCrp /* Euclidean error PROC */

use data_signtest.dta, clear
gen meePROCnorp = (PROCnorp - outcome)^2
sort act
by act: egen TmeePROCnorp = mean(meePROCnorp)
collapse (mean) TmeePROCnorp, by(act)
replace TmeePROCnorp = sqrt(TmeePROCnorp)
collapse (mean) TmeePROCnorp /* Euclidean error PROC ¬ RP */

use data_signtest.dta, clear
gen meenbs = (nbs - outcome)^2
sort act
by act: egen Tmeenbs = mean(meenbs)
collapse (mean) Tmeenbs, by(act)
replace Tmeenbs = sqrt(Tmeenbs)
collapse (mean) Tmeenbs /* Euclidean error NBS */

use data_signtest.dta, clear
gen meenbs_norp = (nbs_norp - outcome)^2
sort act
by act: egen Tmeenbs_norp = mean(meenbs_norp)
collapse (mean) Tmeenbs_norp, by(act)
replace Tmeenbs_norp = sqrt(Tmeenbs_norp)
collapse (mean) Tmeenbs_norp /* Euclidean error NBS ¬ RP */

use data_signtest.dta, clear
gen meecomp = (comp - outcome)^2
sort act
by act: egen Tmeecomp = mean(meecomp)
collapse (mean) Tmeecomp, by(act)
replace Tmeecomp = sqrt(Tmeecomp)
collapse (mean) Tmeecomp /* Euclidean error COMP */

use data_signtest.dta, clear
gen meem_mean = (m_mean - outcome)^2
sort act
by act: egen Tmeem_mean = mean(meem_mean)
collapse (mean) Tmeem_mean, by(act)
replace Tmeem_mean = sqrt(Tmeem_mean)
collapse (mean) Tmeem_mean /* Euclidean error Mean */

use data_signtest.dta, clear
gen meeminimax = (minimax - outcome)^2
sort act
by act: egen Tmeeminimax = mean(meeminimax)
collapse (mean) Tmeeminimax, by(act)
replace Tmeeminimax = sqrt(Tmeeminimax)
collapse (mean) Tmeeminimax /* Euclidean error Minimax */

use data_signtest.dta, clear
gen meecomp2 = (comp2 - outcome)^2
sort act
by act: egen Tmeecomp2 = mean(meecomp2)
collapse (mean) Tmeecomp2, by(act)
replace Tmeecomp2 = sqrt(Tmeecomp2)
collapse (mean) Tmeecomp2 /* Euclidean error COMP (big 5/6) */

use data_signtest.dta, clear
gen meecomp3 = (comp3 - outcome)^2
sort act
by act: egen Tmeecomp3 = mean(meecomp3)
collapse (mean) Tmeecomp3, by(act)
replace Tmeecomp3 = sqrt(Tmeecomp3)
collapse (mean) Tmeecomp3 /* Euclidean error COMP (derived power) */

* Pseudo-R^2 for Table A5
* These values are generated in the variables labelled pseudoR_
use data_signtest.dta, clear
gen mid = ( outcome - 50 )^2
egen Tmid = total(mid)

gen PROCrpADsq=( PROCrp - outcome )^2
egen TPROCrpADsq = total(PROCrpADsq)
gen pseudoR_PROCrp = 1 - (TPROCrpADsq/Tmid) /* Pseudo-R^2 PROC */
label variable pseudoR_PROCrp "Pseudo-R^2 PROC model"
 
gen PROCnorpADsq=( PROCnorp - outcome )^2
egen TPROCnorpADsq = total(PROCnorpADsq)
gen pseudoR_PROCnorp = 1 - (TPROCnorpADsq/Tmid) /* Pseudo-R^2 PROC ¬ RP */
label variable pseudoR_PROCnorp "Pseudo-R^2 PROC ¬ RP model"

gen nbsADsq=( nbs - outcome )^2
egen TnbsADsq = total(nbsADsq)
gen pseudoR_nbs = 1 - (TnbsADsq/Tmid) /* Pseudo-R^2 NBS */
label variable pseudoR_nbs "Pseudo-R^2 NBS model"

gen nbs_norpADsq=( nbs_norp - outcome )^2
egen Tnbs_norpADsq = total(nbs_norpADsq)
gen pseudoR_nbs_norp = 1 - (Tnbs_norpADsq/Tmid) /* Pseudo-R^2 NBS ¬ RP*/
label variable pseudoR_nbs_norp "Pseudo-R^2 NBS ¬ RP model"

gen compADsq=( comp - outcome )^2
egen TcompADsq = total(compADsq)
gen pseudoR_comp = 1 - (TcompADsq/Tmid) /* Pseudo-R^2 COMP */
label variable pseudoR_comp "Pseudo-R^2 COMP model"

gen m_meanADsq=( m_mean - outcome )^2
egen Tm_meanADsq = total(m_meanADsq)
gen pseudoR_m_mean = 1 - (Tm_meanADsq/Tmid) /* Pseudo-R^2 Mean */
label variable pseudoR_m_mean "Pseudo-R^2 Mean model"

gen minimaxADsq=( minimax - outcome )^2
egen TminimaxADsq = total(minimaxADsq)
gen pseudoR_minimax = 1 - (TminimaxADsq/Tmid) /* Pseudo-R^2 Minimax */
label variable pseudoR_minimax "Pseudo-R^2 Minimax model"

gen comp2ADsq=( comp2 - outcome )^2
egen Tcomp2ADsq = total(comp2ADsq)
gen pseudoR_comp2 = 1 - (Tcomp2ADsq/Tmid) /* Pseudo-R^2  COMP (big 5/6)*/
label variable pseudoR_comp2 "Pseudo-R^2 COMP (big 5/6) model"

gen comp3ADsq=( comp3 - outcome )^2
egen Tcomp3ADsq = total(comp3ADsq)
gen pseudoR_comp3 = 1 - (Tcomp3ADsq/Tmid) /* Pseudo-R^2  COMP (derived power) */
label variable pseudoR_comp3 "Pseudo-R^2 COMP (derived power) model"

log close